package com.zlzxm.shoesmarket.view.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityHomeThing;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * CREATE BY zlzxm ON 4/7/21
 */
public class ADHomeThing extends BaseQuickAdapter<EntityHomeThing, BaseViewHolder> {

    public ADHomeThing(@Nullable List<EntityHomeThing> data) {
        super(R.layout.item_home_thing, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, EntityHomeThing entity) {


        int num = holder.getAdapterPosition();
        int icon = 0;

        if(num == 0){

            icon = R.drawable.icon_first;

        }else if(num == 1){
            icon = R.drawable.icon_second;
        }else if(num == 2){
            icon = R.drawable.icon_third;
        }


        holder.setText(R.id.tvTitle,entity.getTitle());
        holder.setText(R.id.tvNum,String.valueOf(num+1));
        holder.setText(R.id.tvDesc,entity.getDesc());
        holder.setText(R.id.tvHot,"热度"+entity.getHotNum());

        ImageView imageView = holder.getView(R.id.ivFace);

        Glide.with(getContext())
                .load(entity.getUrl())
                .into(imageView);

        if(num>2){

            holder.setVisible(R.id.tvNum,true);
            holder.setVisible(R.id.ivNum,false);

        }else {

            holder.setVisible(R.id.tvNum,false);
            holder.setVisible(R.id.ivNum,true);
            holder.setImageResource(R.id.ivNum,icon);

        }


    }
}
